package com.aaa.phone.controller.authenticationcontroller;


import com.aaa.entity.AppIdcardApprove;
import com.aaa.entity.AppStcardApprove;
import com.aaa.entity.AppUserinfo;
import com.aaa.entity.BackSchool;
import com.aaa.phone.service.authenticationservice.AuthenticationService;
import com.aaa.phone.systemconst.ISystemConst;
import com.aaa.util.PictureUtil;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.util.Base64;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @Description: App端实名认证和学生认证
 * @Author: 陈阳
 * @CreateDate: 2018/12/24$ 8:46$
 */
@CrossOrigin
@Controller
@RequestMapping("/authentication")
public class AuthenticationController implements ISystemConst {

    @Autowired
    private AuthenticationService service;

    /**
     * 实名认证
     */
    @RequestMapping("/autonymAuthentication")
    @ResponseBody
    public int autonymAuthentication(AppIdcardApprove appIdcardApprove) {
        return service.updateAutonymName(appIdcardApprove);
    }

    /**
     * 学生认证
     */
    @RequestMapping("/studentAuthentication")
    @ResponseBody
    public int studentAuthentication(AppStcardApprove appStcardApprove)  {
        return service.updateSchoolId(appStcardApprove);
    }

    /***
     * 查询实名认证状态
     */
    @RequestMapping("/queryAutonymAuthentication")
    @ResponseBody
    public int queryAutonymAuthentication(String telephone) {
        return service.queryAA(telephone);
    }

    /**
     * 查询学生认证状态
     */
    @RequestMapping("/queryStudentAuthentication")
    @ResponseBody
    public int queryStudentAuthentication(String telephone) {
       return service.querySA(telephone);
    }

    /**
     * 获取所有的学校
     */
    @RequestMapping("/getSchool")
    @ResponseBody
    public List<BackSchool> getSchool() {
        return service.toGetSchool();
    }

    /**
     * 获取已经实名认证成功的记录
     */
    @RequestMapping("/getAutonymMsg")
    @ResponseBody
    public AppIdcardApprove getAutonymMsg(String telephone) {
        return service.toGetAutonymMsg(telephone);
    }

    /**
     * 获取已经学生认证成功的记录
     */
    @RequestMapping("/getStudentMsg")
    @ResponseBody
    public AppStcardApprove getStudentMsg(String telephone) {
        return service.toGetStudentMsg(telephone);
    }

}
